package com.zmn.oms.model;


import org.apache.commons.lang.builder.ToStringBuilder;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.Date;

/**
 * 类描述：base model
 *
 * @author liuying
 * @date 2018/11/07 17:05
 */
public abstract class BaseModel implements Serializable {

    /**
     * 创建人
     */
    protected String creater;

    /**
     * 最新修改人
     */
    protected String updater;

    /**
     * 创建时间
     */
    protected Date createTime;

    /**
     * 最新修改时间
     */
    protected Date updateTime;

    public String getCreater() {
        return creater;
    }

    public void setCreater(String creater) {
        this.creater = creater;
    }

    public String getUpdater() {
        return updater;
    }

    public void setUpdater(String updater) {
        this.updater = updater;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * toString
     */
    @Override
    public String toString() {

        ToStringBuilder builder = new ToStringBuilder(this);

        Field[] fields = this.getClass().getDeclaredFields();
        try {
            for (Field f : fields) {
                f.setAccessible(true);
                builder.append(f.getName(), f.get(this)).append("\n");
            }
        } catch (Exception e) { // Suppress
            builder.append("toString builder encounter an error");
        }
        return builder.toString();
    }
}